home *** CD-ROM | disk | FTP | other *** search
Text File | 1991-11-08 | 4.8 KB | 174 lines | [TEXT/AAIS] |
- /* PLAMSELP: HyperExpert for plastic material and process selection.
-
- Copy Right: Life-cycle Engineering Group at Ohio State University (LEGOS)
- Authors: K. Beiter, K. Ishii, S. Krizan, L. Hornberger (Apple)
- HyperCard / IM support: Steven Weyer, Ruben Kleiman (Apple, ATG)
-
- Revision record:
- 6/24/90 Version 1.0 Commented. Good for 70 materials
- Use "findall" instead of "findall" when running this program under AAIS prolog
- Convert to IM code using IM convert, name it rules.p
- then, use with PLAMSELP stack and PLASTICS stack, also with data.p
- IM version must use "findall"
-
- */
-
- /* 6/12/90 Since max_val_asserting takes a lot of time, we decided to assert arbitrary
- Values here. Future version should do this in HyperTalk and add it to data.p rather
- than rules.p */
-
- max_val_prop_asserted(uts, 12000.01, max).
- max_val_prop_asserted(izod, 15.01, max).
- max_val_prop_asserted(hdt, 400.01, max).
- max_val_prop_asserted(spec_grav, 5.01, max).
- max_val_prop_asserted(tms, 5.01, max).
-
- /* sub_points fetches the attribute value of an attribute, normalizes it with the
- maximum attribute value out of the polymer set, then multiplies it with a coefficient. */
-
- sub_points(Polyname, Att, Score)
- :- attribute(Att, Polyname, Rawscore),
- max_val_prop_asserted(Att, MaxVal, MaxPlyname),
- coeff(Att, Num),
- Score is Rawscore *Num/ MaxVal.
-
- total_points(Polyname, Name_and_score)
- :- attribute_set(List_of_attributes),
- total_points_aux(Polyname, List_of_attributes, Name_and_score).
-
- total_points_aux(Polyname,[],0.001).
- total_points_aux(Polyname,[First|Rest], Score)
- :- total_points_aux(Polyname,Rest, Rscore),
- sub_points(Polyname, First, Subscore),
- Score is Rscore + Subscore.
-
-
- % this predicate checks to see if a particular material meets the minimum requirment Att
-
- qualify(Mat_name, Att, Min_req_val)
- :- attribute(Att, Mat_name, Att_val),
- X is Att_val + 1000.021,
- Y is Min_req_val + 1000.021,
- X >= Y.
-
- /* this predicate tries to see if a material meets minimum values for a list of attributes,
- and returns a list of attribute names and corresponding values.
- */
-
- qualify_list(Mat_name, []).
- qualify_list(Mat_name, [(Att, Min_req_val)|Rest_of_att_and_minval])
- :- qualify(Mat_name, Att, Min_req_val),
- qualify_list(Mat_name, Rest_of_att_and_minval).
-
-
- /* Rev. 6/24/90 quant_prune is no longer used */
-
- /* cutoff_assert asserts a list of cutoffs (Att_name, Mininum requirement) as read from
- HyperExpert */
-
- cutoff_assert
- :- findall((Att_name, Min_req), cutoff(Att_name, Min_req), List_of_cutoffs),
- assertz(qual_list(List_of_cutoffs)).
-
-
- /* Actual triggers for qualitative */
-
-
- doit4(Ans)
- :- findall((Polyname), candidate(Polyname), List_of_polymers),
- doit41(List_of_polymers, Ans).
-
- /* candidate gives a prunes list of Polymers */
- candidate(Polyname)
- :- polymer(Type, Polyname),
- ok_by_type(Type),
- ok_by_cutoffs(Polyname).
-
- ok_by_type(Type)
- :-
- type_list(Type_list),
- mymember(Type, Type_list).
-
- ok_by_cutoffs(Polyname)
- :-
- qual_list(List_of_cutoffs),
- qualify_list(Polyname, List_of_cutoffs).
-
- doit41([],[]).
- doit41([First|Rest], [(First,Fans)|Rans])
- :- total_points(First, Fans),
- doit41(Rest, Rans).
-
- doit5 :- doit4(Ans), plist(Ans).
-
- doit6(Num, Final_ans)
- :- doit4(Unsorted_ans),
- quicksort(Unsorted_ans, Sorted_ans),
- truncate_list(Num, Sorted_ans, Final_ans).
-
- doit7(Q)
- :- doit6(Q, Final_ans),
- plist(Final_ans).
-
- /* Actual triggers for quantitative stuff */
-
-
- /* utilities */
- plist([]).
- plist([First|Rest]):- write(First), nl,plist(Rest).
-
- get_head_of_cons([],[]).
- get_head_of_cons([(A,B)|Rest],[A|Grest])
- :- get_head_of_cons(Rest, Grest).
-
- get_tail_of_cons([],[]).
- get_tail_of_cons([(A,B)|Rest],[B|Grest])
- :- get_tail_of_cons(Rest, Grest).
-
- quicksort([],[]).
- quicksort([X|Tail],Sorted)
- :-split(X, Tail, Small, Big),
- quicksort(Small, SortedSmall),
- quicksort(Big, SortedBig),
- conc(SortedSmall, [X|SortedBig],Sorted).
-
- conc([],L,L).
- conc([X|L1],L2, [X|L3])
- :-conc(L1, L2, L3).
-
- split(X, [],[],[]).
- split(X, [Y|Tail], [Y|Small], Big)
- :- gt(X, Y), !, split(X, Tail, Small, Big).
- split(X, [Y|Tail], Small, [Y|Big])
- :- split(X, Tail, Small, Big).
-
- gt((AX, AY), (BX, BY))
- :- VY is AY + 1000.021,
- WY is BY + 1000.021,
- VY < WY.
-
- truncate_list(Any, [], []).
- truncate_list(0, Ans, []).
- truncate_list(N, [F|R], [F|Rans])
- :- N1 is N-1,
- truncate_list(N1, R, Rans).
-
- % mymemeber(+element, +set) returns true if the element is a member of the set
- mymember(Element, [Element|Rest]).
- mymember(Element, [First|Rest])
- :- mymember(Element, Rest).
-
- rev([], Any).
- rev([First|Rest], Ans)
- :- rev(Rest, Rlist),
- myappend(Rlist, [First], Ans).
-
- myappend([],L,L).
- myappend([X|L1], L2, [X|L3])
- :- myappend(L1, L2, L3).
-
- type_list([polycarbonate, abs]).
-
- attribute_set([uts, izod, hdt, spec_grav, tms]).
-
-